package com.sztz.mapstruct.Q映射注解复用;

import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * CarMapper
 *
 * @author yyf
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {

    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);

    /**
     * 简单映射
     *
     * @param car
     * @return CarDto
     */
    @Mapping(source = "name", target = "carName")
    CarDTO toDto(Car car);

    /**
     * 复用 toDto的Mapping信息
     * 若有多个映射需指定name
     *
     * @param car
     * @return CarDTO
     */
    @InheritConfiguration
    CarDTO toDto2(Car car);
}
